﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Bird.Core.ComponentModel
{
    public class ReaderLock:IDisposable
    {
        ReaderWriterLock _lock;

        public ReaderLock(ReaderWriterLock @lock)
        {
            if (@lock == null)
                throw new ArgumentNullException("lock");
            @lock.AcquireReaderLock(Timeout.Infinite);
            _lock = @lock;
        }

        public void Dispose()
        {
            _lock.ReleaseReaderLock();
        }
    }
}
